home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 3.8 KB | 173 lines | [TEXT/MSET] |
- (*
-
- A selection object. The scrollbars are fully functional and will respond to
- mouse clicks without additional setup. Scrolling is accomplished by
- sending late bound messages to a second object, the object to be scrolled,
- which we call the OwnerObject.
-
- The default object to be scrolled is nullOwnerObject which accepts the
- required messages from the scrollbar ( prescroll:, postscroll:, and draw:).
- We can have the scrollbar control any other object by using the
- scrolledby: method. Of course we must define methods that behave
- properly to the scrollbar messages.
-
- See the use of scrollbars in classes tescroll, editlist, and pictscroll.
-
- Note that the number of pixels to scroll and the max and min
- control values must be set up as well. Default values
- are provided that are reasonable. Perhaps we should have a method
- that inspects the object to be scrolled for those values? Also, the
- rectangle to scroll must be set up via setscrollrect:.
-
- *)
-
-
- :class OwnerObj super{ object }
-
- :m prescroll: ;m
- :m postscroll: ;m
- :m draw: ;m
-
- ;class
-
- OwnerObj nullOwnerObject
-
-
- :class vscrollBar super{ baseControl }
- int controlWas
- dicaddr scrollObject
- int pixDelta \ number of pixels to scroll corresponding to up/dn arrow
- int pageN \ pixDelta multiplier corresponding to page up/dn
- rect+ scrollRect
- int lo
- int hi
- handle theregion
-
- :m setScrollRect: ( l t r b -- )
- put: scrollRect ;m
-
- :m setScrollValues: ( pixdelta pageN -- )
- put: pageN put: pixDelta ;m
-
- :m >RECT: { x y len -- left top rt bot }
- x y x 16 + y len + ;m
-
- :m init: ( x y len -- )
- >RECT: self put: bounds ;m
-
- :m scrolledBy: ( obj -- )
- put: scrollObject ;m
-
- :m set: ( n -- )
- dup put: super
- put: controlWas ;m
-
- :m new: { wptr -- } \ must be compatible with selection objects
- wptr put: wind
-
- 0 \ room for ControlHandle
- wptr \ theWindow
- addr: bounds \ boundsRect
- nullOSstr \ title
- true tbool \ visible
- get: super makeint \ value
- int: lo int: hi \ min,max
- int: procid
- self \ refcon
- call NewControl put: ctlHndl
- ;m
-
- :m deactivate: \ Sets the control to 255 hiliting (disabled)
- 255 hilite: super ;m
-
- :m PUTRANGE: { l h -- }
- alive?: self
- IF
- get: ctlHndl l makeInt call SetMinCtl
- get: ctlHndl h makeInt call SetMaxCtl
- THEN
- l put: lo
- h put: hi ;m
-
- :m getrange: ( -- lo hi )
- get: lo get: hi \ we always maintain these
- ;m
-
- :m classinit:
- 20 ( x ) 20 ( y ) 100 ( len ) init: self
- konst scrollBarProc put: procID
- 1 10 setScrollValues: self
- 0 0 0 0 setScrollRect: self
- 0 100 putrange: self
- nullOwnerObject put: scrollObject \ 06Mar94 DBH, ok because using dicaddr
- ;m
-
- :m windRegion: ( -- rgn )
- get: wind 122 + @ ;m
-
- :m dh: ( -- dh )
- 0 ;m
-
- :m dv: ( -- dv )
- get: controlWas get: self - get: pixDelta * ;m
-
- :m ScrollOnce:
- addr: scrollRect
- dh: [self]
- dv: [self]
- pack
- windRegion: self
- call ScrollRect
- get: self put: controlWas
- windRegion: self call ValidRgn
- draw: [ get: scrollObject ] \ force a draw
- ;m
-
- \ we late bind in DoCtl: and DoThumb: to allow for a different ScollOnce:
- \ in text edit scrolls and hscrolls
-
- :m DoCtl: ( n -- )
- get: self + put: self
- ScrollOnce: [self] ;m
-
- :m DoThumb:
- ScrollOnce: [self] ;m
-
- :m prescroll:
- prescroll: [ get: scrollObject ] ;m
-
- :m postscroll:
- postscroll: [ get: scrollObject ] ;m
-
- CallFirst prescroll:
- CallLast postscroll:
-
-
- \ exec: will be called via click: in superclass
-
- :m exec: ( part# -- )
- CASE
- konst inThumb OF DoThumb: self ENDOF
- konst inUpButton OF -1 DoCtl: self ENDOF
- konst inDownButton OF 1 DoCtl: self ENDOF
- konst inPageUp OF get: pageN negate DoCtl: self ENDOF
- konst inPageDown OF get: pageN DoCtl: self ENDOF
- ENDCASE
- ;m
-
- :m release:
- release: super
- nullOwnerObject put: scrollObject ;m \ 29Jul94 DBH so we don't crash upon next new:
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- selwindow w
- test: w
-
- vscrollbar v
- v add: w
-